package pl.edu.mimuw.irs.rcp.controller.editor.workflow.command;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.requests.BendpointRequest;

import pl.edu.mimuw.irs.core.util.RelativePosition;

public class CreateBendpointCommand extends AbstractBendpointCommand {

	// *** Constructors

	public CreateBendpointCommand(BendpointRequest request) {
		super(request);
	}

	// *** Methods
	
	@Override
	public void execute() {
		List<RelativePosition> vertices = 
			new ArrayList<RelativePosition>(getArc().getVertices());
		vertices.add(getIndex(), getPosition());
		getArc().setVertices(vertices);
		super.execute();
	}

	@Override
	public void undo() {
		List<RelativePosition> vertices =
			new ArrayList<RelativePosition>(getArc().getVertices());
		vertices.remove(getPosition());
		getArc().setVertices(vertices);
		super.execute();
	}
}
